#ifndef _UTILEX_THREAD_H_
#define _UTILEX_THREAD_H_

#include <compat/thread.h>

#ifdef __cplusplus

	class ithread 
	{
	public:
		ithread() {

		}
		virtual ~ithread() {

		}
		bool start_thread() {
			os_thread_create(&thread, ithread::thread_proc,this);
			return true;
		}

		bool stop_thread() {
			join();
			this->threadstop();
			return true;
		}
		bool join() {
			os_thread_join(&thread);
			return true;
		}
		static void thread_proc(void* pthis) {

			ithread* p = static_cast<ithread*>(pthis);
			p->run();

		}

	protected:
		virtual void run()			= 0;
		virtual void threadstop()	= 0;
		os_thread_t					thread;
	};
#endif


#endif